package com.fly.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 
 * multipartResolver @Configuration 与 spring-mvc.xml 注册 multipartResolver 等价
 * 
 * @author 00fly
 * @version [版本号, 2021年2月16日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
//@Configuration
@EnableWebMvc
@ComponentScan("com.fly")
public class WebMvcConfig extends WebMvcConfigurerAdapter
{
    
    /**
     * 注册 multipartResolver
     * 
     * @return
     * @see [类、类#方法、类#成员]
     */
    @Bean
    public CommonsMultipartResolver multipartResolver()
    {
        CommonsMultipartResolver resolver = new CommonsMultipartResolver();
        resolver.setDefaultEncoding("utf-8");
        resolver.setMaxInMemorySize(0);
        resolver.setMaxUploadSizePerFile(5 * 1024 * 1024L);
        resolver.setMaxUploadSize(10 * 1024 * 1024L);
        return resolver;
    }
}